<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>时钟练习</title>
</head>
<body>
<div id="timetxt"></div>
<script>
    function startTime(){
        var today=new Date();
        var h=today.getHours();
        var m=today.getMinutes();
        var s=today.getSeconds();
        m=checkTime(m);
        s=checkTime(s);
        document.getElementById("timetxt").innerHTML=h+":"+m+":"+s;
        t=setTimeout(function () {
        startTime();
            },1000);
    }
    var i=startTime();
    function checkTime(j) {
       if (j<10){
           j="0"+1;
       }else{
           return j;
       }

    }
</script>

</body>
</html>